package com.fleapx.spring.hook.springhooktest.applicationlistener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 这是一个典型的观察者模式,当容器上下文中发布一个ApplicationEvent子类之后，会在该类中的onApplicationEvent方法中得到回调；具体的发布事件可参考ApplicationContextAware中
 */
@Component
public class ApplicationListenerTest implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        Object sb = applicationEvent.getSource();
        System.out.println("++++++++++++++++:"+sb.toString());
    }
}
